
import request from '@/utils/Request.js'
const url = import.meta.env.VITE_API_BASE_URL

// menu apis
export function getMenuList() {
    return request({
        url:`${url}/sys/menu/getMenuList`,
        method:'post'
    })
}

export function getMenus() {
    return request({
        url:`${url}/sys/menu/getMenus`,
        method:'post'
    })
}

export function createMenu(data) {
    return request({
        url:`${url}/sys/menu/create`,
        method:'post',
        data: data,
        headers: {
            'Content-Type': 'application/x-www-form-urlencoded'
        }
    })
}

export function updateMenu(data) {
    return request({
        url:`${url}/sys/menu/update`,
        method:'post',
        data: data,
        headers: {
            'Content-Type': 'application/x-www-form-urlencoded'
        }
    })
}

export function queryMenu(data) {
    return request({
        url:`${url}/sys/menu/query?id=${data.id}`,
        method:'post',
        data: data,
        headers: {
            'Content-Type': 'application/x-www-form-urlencoded'
        }
    })
}

export function delMenu(data) {
    return request({
        url:`${url}/sys/menu/del`,
        method:'post',
        data: data,
        headers: {
            "Content-Type": "application/json"
        }
    })
}

// mind apis
export function getMindConfig() {
    return request({
        url:`${url}/sys/mindmap/options`,
        method:'post'
    })
}

export function getMindList(data) {
    return request({
        url: `${url}/sys/mindmap/getMindList`,
        method: 'post',
        data: data,
        headers: {
            'Content-Type': 'multipart/form-data'
        }
    })
}

export function getMindInfo(){
    return request({
        url: `${url}/sys/mindmap/getMindInfo`,
        method: 'post',
    })
}

export function getMindById(data){
    return request({
        url: `${url}/sys/mindmap/getMindById`,
        method: 'post',
        data: data
    })
}

export function createMind(data){
    return request({
        url: `${url}/sys/mindmap/create`,
        method: 'post',
        data:data,
    })
}

export function updateMind(data){
    return request({
        url: `${url}/sys/mindmap/update`,
        method: 'post',
        data:data,
    })
}

export function deleteMindById(data) {
    return request({
        url: `${url}/sys/mindmap/delete`,
        method: 'post',
        data:data,
    })
}

export function importFileForXmind(data){
    return request({
        url: `${url}/sys/mindmap/upload`,
        method: 'post',
        data: data,
        headers: {
            'Content-Type': 'multipart/form-data'
        }
    })
}


export function importFileForJson(file){
    console.log("导入文件")
}

export function exportFile(id, path, t){
    console.log("导出文件")
}

// user apis
export function getUserList() {
    return request({
        url: `${url}/sys/user/getUserList`,
        method: 'post',
    })
}

export function createUser(data) {
    return request({
        url: `${url}/sys/user/create`,
        method: 'post',
        data: data,
        headers: {
            'Content-Type': 'application/x-www-form-urlencoded'
        }
    })
}

export function updateUser(data) {
    return request({
        url: `${url}/sys/user/update`,
        method: 'post',
        data: data,
        headers: {
            'Content-Type': 'application/x-www-form-urlencoded'
        }
    })
}

export function queryUser(data) {
    return request({
        url: `${url}/sys/user/query?id=${data.id}`,
        method: 'post',
        data: data
    })
}

export function delUser(data) {
    return request({
        url:`${url}/sys/user/del`,
        method:'post',
        data: data,
        headers: {
            "Content-Type": "application/json"
        }
    })
}

// group manager
export function getGroupList() {
    return request({
        url: `${url}/sys/group/getGroupList`,
        method: 'post',
    })
}

export function createGroup(data) {
    return request({
        url: `${url}/sys/group/create`,
        method: 'post',
        data: data,
        headers: {
            'Content-Type': 'application/x-www-form-urlencoded'
        }
    })
}

export function updateGroup(data) {
    return request({
        url: `${url}/sys/group/update`,
        method: 'post',
        data: data,
        headers: {
            'Content-Type': 'application/x-www-form-urlencoded'
        }
    })
}

export function queryGroup(data) {
    return request({
        url: `${url}/sys/group/query/filter?id=${data.id}`,
        method: 'post',
        data: data,
    })
}

export function delGroup(data) {
    return request({
        url:`${url}/sys/group/del`,
        method:'post',
        data: data,
        headers: {
            "Content-Type": "application/json"
        }
    })
}

// api manager
export function getApiList(){
    return request({
        url: `${url}/sys/api/list`,
        method: 'post'
    })
}

export function queryApi(data){
    return request({
        url: `${url}/sys/api/query?id=${data.id}`,
        method: 'post',
        data: data,
        headers: {
            'Content-Type': 'application/x-www-form-urlencoded'
        }
    })
}

export function createApi(data){
    return request({
        url: `${url}/sys/api/create`,
        method: 'post',
        data: data,
        headers: {
            'Content-Type': 'application/x-www-form-urlencoded'
        }
    })
}

export function updateApi(data){
    return request({
        url: `${url}/sys/api/update`,
        method: 'post',
        data: data,
        headers: {
            'Content-Type': 'application/x-www-form-urlencoded'
        }
    })
}

export function deleteApi(data) {
    return request({
        url:`${url}/sys/api/del`,
        method:'post',
        data: data,
        headers: {
            "Content-Type": "application/json"
        }
    })
}


// bug manager
export function getBugList(){
    return request({
        url: `${url}/sys/bug/list`,
        method: 'post',
        headers: {
            "Content-Type": "application/json"
        }
    })
}